$(function(){
	var reports = echarts.init($('#report')[0]);
	function dataForCharts(d){
		var X = [];
		var D = [];
		var D1 = [];
		var D2 = [];
		for (var i in d.m){
			X[i] = d.m[i].hour;
			D[i] = d.m[i].val;
			D1[i] = Math.floor(d.m[i].val * (Math.random() + 0.4));
			D2[i] = Math.floor(d.m[i].val * (Math.random() + 0.4));
		}
		var option = {
			title:{
				text:'今天的广告数据',
				left:'middle'
			},
			tooltip:{
				show:true,
				//showConent: ,
				trigger:'axis',
				//formatter:'{b}',
				axisPointer:{
					type:'line',
					axis:'x'
				}
			},
			legend:{
				left:'right',
				top:'middle',
				orient:'vertical',
				data:[{
					name:'点击'
				},{
					name:'弹窗'
				},{
					name:'富媒体'
				}]
			},
			grid:{
				width:'80%'
			},
			xAxis:{
				type:'',
				data:X,
				boundaryGap:true,
				name:'每小时数据',
				axisTick:{
					alignWithLabel:true,
				}
			},
			yAxis:{
			},
			series:[{
				name:'点击',
				type:'line',
				data:D,
				smooth:true
			},{
				name:'弹窗',
				type:'line',
				data:D1,
				smooth:true
			},{
				name:'富媒体',
				type:'line',
				data:D2,
				smooth:true
			}]
		};
	//	reports.setOption(option);
	//	$(window).resize(reports.resize)
	}
	//http://58.51.95.51:82/ck/Api/master/siter_num_group_by_hour.php?id=15278&day=2017-2-6
	 $.ajax({
			 type: "get",
			 async: false,
			 url: "http://58.51.95.51:82/ck/Api/master/siter_num_group_by_hour.php?id=15278&day=2017-2-7",
			 dataType: "jsonp",
			 jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(一般默认为:callback)
			 jsonpCallback:"flightHandler",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名，也可以写"?"，jQuery会自动为你处理数据
			 success: dataForCharts,
			 error: function(){
				 alert('fail');
			 }
	});
})

